#include <iostream>

using std::cout;
using std::endl;

#if 0
template <typename T1, typename T2, typename T3, typename T4>
void func(T1 x, T2 y, T3 z, T4 a)
{

}
#endif

template <typename ...Args>//Args称为模板参数包,
void func(Args ...args)//args称为函数参数包
{
    //...位于Args的左边，称为打包
    cout << "sizeof...(Args) = " << sizeof...(Args) << endl;
    cout << "sizeof...(args) = " << sizeof...(args) << endl;
    /* cout <<"...args" << ...args << endl;//error */
    /* cout <<"...args" << ...(args) << endl;//error */
    /* cout <<"...args" << (args...) << endl;//error */
    /* cout <<"...args" << (args)... << endl;//error */
}

void test()
{
    func();
    //template <typename T>
    //void func(T t)//T = int, t = 1
    //{
    //
    //}
    func(1);
    func(1, "hello");
    func(1, "hello", true);
    func(false, 1.1, "hello", true);
}

void print()
{
    cout << endl;
}

//可变模板参数本质就是一个递归的过程
//就任务有n个参数，1 n -1
//n = 10    1    1  1  1  
template <typename T, typename ...Args>
void print(T t, Args ...args)
{
    cout << t << "  ";
    print(args...);//...位于args的右边的称为解包
}

void test2()
{
    print();
    print(1);
    print(1, "hello");
    print(1, "hello", true, 3.3);
    //cout << 1 << " ";
    //print("hello", true, 3.3);
    //   cout << "hello" << "  ";
    //   print(true, 3.3)
    //      cout << 1 << "  ";
    //      print(3.3);
    //          cout << 3.3 << "  ";
    //          print();
    //            cout << endl;
}

int main(int argc, char *argv[])
{
    test2();
    return 0;
}

